/*
 * 自己的JS脚步
 * @Author: iceStone
 * @Date:   2015-12-12 10:59:26
 * @Last Modified by:   iceStone
 * @Last Modified time: 2015-12-12 11:01:38
 */

'use strict';

$(function(){
	function resize() {
		var windowWidth = $(window).width();
		var isSmallScreen = windowWidth < 768;
		$("#mian_add > .carousel-inner > .item").each(function(i,item) {
			var $item = $(item);
			var imgSrc=$item.data(isSmallScreen?'img-xs':'img-lg');

			if(isSmallScreen){
				$item.css("backgroundImage",'')
				$item.html("<img src='"+imgSrc+"'/>");
			}else{
				$item.html("");
				$item.css("backgroundImage",'url('+imgSrc+')')
			}
		})		
	}
	$(window).on("resize",resize).trigger('resize');


	/**
	 * 控制标签页的宽度
	 */
	
	var ulContainer = $(".nav-tabs");
	var liWidth=30;
	ulContainer.children().each(function(i,item) {
		liWidth +=item.clientWidth;
	})

	/**
	 * 判断当前屏幕宽与ul宽度大小
	 *
	 */
	if(liWidth>$(window).width()){
		ulContainer.css("width",liWidth);	
	}
	
})
